/* 
 * File:   main.cpp
 * Author: amois
 *
 * Created on 29 Сентябрь 2009 г., 19:34
 */

#include <stdlib.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <exception>

#include "metro/Line.h"
#include "metro/Station.h"
#include "metro/lines_provider.h"
/*
 * 
 */
using namespace std;
const int station_num = 10;
string _(string s)
{
	return s;
}
int testsCount(1);
int testsPassed(0);

void itLines(Line* l)
{
	cout << l->getName() << "\t#" << l->getNumber() << endl;
}

void testGetLine(string &n)
{
    n = "testGetLine";
    lines_provider* lpp = new lines_provider();
    std::vector<Line*> lp = lpp->getLines();
    for_each(lp.begin(), lp.end(), itLines);
//    exception e;  throw e;
}

void test(void (*f)(string&))
{
    
    string n;
    try
    {
	    f(n);
	    testsPassed++;
	    cout << _("Тест ") << n << _(" пройден.") << endl;

    }
    catch(exception e)
    {
	    cerr << _("Тест ") << n <<  _(" не пройден.") << endl;
	    cerr << e.what() << endl;
    }
}
int
main(int ac, char** av)
{
    Line *l = new Line(2, "Sinyaya", 4);
    if(l->getName() != "Sinyaya")
    {
        cerr << "names not equal" << endl;
        return (EXIT_FAILURE);
    }

    test(testGetLine);
    cout << endl; 
   cout << _("Пройдено: ") << testsPassed << _(", не пройдено: ") << testsCount - testsPassed << endl;
   return (EXIT_SUCCESS);
}

